// 表单校验规则由 schema2code 生成，不建议直接修改校验规则，而建议通过 schema2code 生成, 详情: https://uniapp.dcloud.net.cn/uniCloud/schema


const locaLang = uni.getLocale()
const validator = {
	"real_name": {
		"rules": [{
			"format": "object"
		}, {
			validateFunction: (rule, value, data, callback) => {
				if (!value[locaLang]) {
					callback('姓名为必填')
					return false
				}
				return true
			}
		}],
		"label": "姓名"
	},
	"email": {
		"rules": [{
				"format": "string"
			},
			{
				"format": "email"
			}
		],
		"label": "邮箱"
	},
	"mobile": {
		"rules": [{
				"required": true
			},
			{
				"format": "string"
			},
			{
				"pattern": "^\\+?[0-9-]{3,20}$"
			}
		],
		"label": "手机号"
	},
	"mobile_area_code": {
		"rules": [{
			"format": "string"
		}],
		"label": "国际区号"
	},
	"organization": {
		"rules": [{
			"format": "object"
		}],
		"label": "机构或公司"
	},
	"online": {
		"rules": [{
			"format": "bool"
		}],
		"label": "是否营业"
	},
	"score": {
		"rules": [{
			"format": "double"
		}],
		"label": "评分"
	},
	"serviceTime": {
		"rules": [{
			"format": "string"
		}],
		"label": "服务时间"
	},
	"src": {
		"rules": [{
			"format": "string"
		}],
		"label": "店铺logo"
	},
	"state": {
		"rules": [{
			"format": "bool"
		}],
		"label": "是否启用"
	}
}

const enumConverter = {
	"deliveryTypes_valuetotext": [{
			"text": "配送到家",
			"value": "deliveryHome"
		},
		{
			"text": "快递",
			"value": "express"
		},
		{
			"text": "到店/自提点自提",
			"value": "selfRaising"
		}
	]
}

export {
	validator,
	enumConverter
}